import 'dart:convert';

import 'package:bloc_usage/model/response_wrapper.dart';
import 'package:dio/dio.dart';

class HttpUtil {
 static Dio _dio = Dio();

  static Future<ResponseWrapper<T>> get<T>(String path) async {
    Response response = await _dio.get(path);
    if (response.statusCode == 200) {
      Map<String, dynamic> map = response.data;
      T _data;
      String errMsg;
      int errCode;

      errMsg = map["errorMsg"];
      errCode = map["errorCode"];
      _data = map["data"];
      return ResponseWrapper<T>(errCode, errMsg, _data);
    } else
      return Future.error("json decode error");
  }
}
